<template>
	<view class="content">
        <u-navbar :fixed="true" :shadow="true" :safeAreaInsetTop="true" :placeholder="true"
            @leftClick="back" title="人员详情">
        </u-navbar>

        <view class="uni-area">
            <!-- 人员信息 -->
            <view class="u-m-t-30 uni-shadow" style="overflow:hidden">
                <!-- 基本信息 -->
                <view class="u-flex u-col-top up">
                    <u--image :showLoading="true" :src="staffInfo.profile?staffInfo.profile:'/static/logo.png'"
                        radius="8" width="160rpx" height="160rpx">
                    </u--image>
                    <view class="u-m-l-30 u-font-28 uni-dec-color">
                        <text class="u-font-36 font-bold uni-main-color">{{staffInfo.xm}}</text>
                        <view class="u-m-t-30 u-font-28 uni-dec-color info">
                            <text class="info_item">{{staffInfo.xb?staffInfo.xb:'男'}}</text>
                            <text class="info_item">{{staffInfo.mz?staffInfo.mz:'汉'}}</text>
                            <text class="info_item">{{staffInfo.jiGuan?staffInfo.jiGuan:'暂无籍贯信息'}}</text>
                        </view>
                        <view class="u-m-t-20 uni-dec-color" v-if="!staffInfo.zjhm">{{staffInfo.zjhm}}</view>
                        <view class="u-m-t-20 uni-dec-color" v-else>{{$tools.formatIdentity(staffInfo.zjhm)}}</view>
                        <view class="u-m-t-20 u-flex">
                            <uni-phone class="u-m-r-20" :phone="staffInfo.lxfs" :size="15"/>
                            <u-icon name="phone-fill" color="#21A5F3"></u-icon>
                        </view>
                    </view>
                    <!-- 认证 -->
                    <u-button class="authentication" type="warning" shape="circle" text="">
                        <text class="u-font-24">{{staffInfo.smrz}}</text>
                    </u-button>
                </view>
                <!-- 菜单操作 -->
                <view class="u-m-t-60 u-flex u-row-between u-p-l-30 u-p-r-30">
                    <view v-for="(item,index) in infoBtns" :key="index"
                        class="u-flex u-flex-col" @tap.stop="menuSkip(index)">
                        <u-icon :name="item.icon" size="29"></u-icon>
                        <text class="u-m-t-20 u-font-28 uni-dec-color">{{item.title}}</text>
                    </view>
                </view>
            </view>

            <!-- 当前企业信息 -->
            <uni-item-base class="u-m-t-30" :baseData="enterpriseData" @rightTopClick="entDetail" />
            <!-- 当前项目信息 -->
            <uni-item-base class="u-m-t-30" :baseData="projectData" @rightTopClick="proDetail" @lookClick="teamDetail"/>
            <!-- 人员信息 -->
            <uni-item-base class="u-m-t-30" :baseData="staffData" />
            <!-- 合同信息 -->
            <uni-item-base class="u-m-t-30" :baseData="contractInfo" />
            <!-- 其它信息 -->
            <uni-item-base class="u-m-t-30" :baseData="otherInfo" />

            <!-- 附件  -->
            <uni-accessory class="u-m-t-30" :accessorys="accessoryList" />
        </view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
                // 账号信息
                userInfo: uni.getStorageSync("userInfo"), 

                // 人员信息
                staffInfo:{
                    profile: '/static/logo.png',
                    xm: '安薪乐',
                    xb: '男',
                    mz: '汉',
                    jiGuan: '新疆',
                    zjhm: '513022202001011234',
                    lxfs: '18302882468',
                    smrz: '未认证',
                },

                // 菜单操作
                infoBtns:[
                    { title:'考勤', icon:'/static/member/member1.png' },
                    { title:'工资', icon:'/static/member/member2.png' },
                    { title:'信用', icon:'/static/member/member4.png' },
                    { title:'其它', icon:'/static/member/member3.png' }
                ],

                // 当前单位(企业)信息
                enterpriseData:{
                    line: false,
                    title: '所属单位信息',
                    rightText: '查看',
                    list:[
                        { field:'qymc', title:'单位名称', value:'安薪乐' }, 
                        { field:'tyshxydm', title:'统一社会信用代码', value:'安薪乐' },
                    ]
                },
                // 当前项目信息
                projectData:{
                    line: false,
                    title: '当前项目信息',
                    rightText: '查看',
                    list:[
                        { field:'gcmc', title:'项目名称', value:'' },
                        { field:'xmdz', title:'项目地址', value:'' },
                        { field:'constructionxmjlname', title:'项目经理', value:'' },
                        { field:'constructionxmjllxdh', title:'项目经理联系电话', value:'', type:'phone' },
                        { field:'bzmc', title:'班组名称', value:'', type:'look' },
                        { field:'gwlx', title:'角色', value:'' },
                        { field:'drzw', title:'从事工种', value:'' },
                        { field:'jcsj', title:'进场时间', value:'' },
                        { field:'lcsj', title:'离场时间', value:'' }
                    ]
                },
                // 人员信息
                staffData:{
                    line: false,
                    title: '人员信息',
                    rightText: '',
                    list:[
                        { field:'rylx', title:'人员类型', value:'安薪乐', },
                        { field:'hjszd', title:'身份证住址', value:'安薪乐', },
                        { field:'yxksrq', title:'身份证有效起始日期', value:'安薪乐' },
                        { field:'yxjsrq', title:'身份证有效终止日期', value:'安薪乐' },
                        { field:'qfjg', title:'签发机构', value:'安薪乐' },
                        { field:'sjzz', title:'实际住址', value:'安薪乐' },
                        { field:'gzklb', zdv:'gzklb', title:'工资卡类别', value:'安薪乐' },
                        { field:'khhyh', title:'工资卡开卡银行', value:'安薪乐' },
                        { field:'khhdm', title:'工资卡开卡行号', value:'安薪乐' },
                        { field:'gzkkh', title:'工资卡卡号', value:'安薪乐' },
                    ]
                },
                // 合同信息
                contractInfo:{
                    line: false,
                    title: '合同信息',
                    rightText: '',
                    list:[
                        { field:'htlx', zdv:'htlx', title:'合同类型', value:'安薪乐' },
                        { field:'htqdsj', zdv:'', title:'合同签订日期', value:'安薪乐' },
                        { field:'htqssj', zdv:'', title:'合同起始日期', value:'安薪乐' },
                        { field:'htzzsj', zdv:'', title:'合同终止日期', value:'安薪乐' },
                        { field:'lwhtbh', zdv:'', title:'合同编号', value:'安薪乐' },
                        { field:'gzjsfs', zdv:'jxfs', title:'工资计算方式', value:'安薪乐' },
                        { field:'gzbz', zdv:'', title:'工资标准', value:'安薪乐' },
                        { field:'gzzfrq', zdv:'', title:'工资支付日期', value:'安薪乐' },
                        { field:'ksgzrq', zdv:'', title:'开始工作日期', value:'安薪乐' }
                    ]
                },
                // 其它信息
                otherInfo:{
                    line: false,
                    title: '其它信息',
                    rightText: '',
                    list:[
                        { field:'sfcjjbaqpx', zdv:'shifou', title:'是否参加基本安全培训', value:'' },
                        { field:'zcgwzs', zdv:'', title:'职称/岗位证书', value:'' },
                        { field:'jnspdj', zdv:'', title:'技能水平/等级', value:'' },
                        { field:'hyzk', zdv:'hyzk-cxcj', title:'婚姻状况', value:'' },
                        { field:'zzmm', zdv:'zzmm', title:'政治面貌', value:'' },
                        { field:'sfjrgh', zdv:'shifou', title:'是否加入工会', value:'' },
                        { field:'jrghsj', zdv:'', title:'加入工会时间', value:'' },
                        { field:'sfyzdjbs', zdv:'shifou', title:'是否有重大疾病史', value:'' },
                        { field:'jjlxrxm', zdv:'', title:'紧急联系人姓名', value:'' },
                        { field:'jjlxdh', zdv:'', title:'紧急联系人电话', value:'' },
                    ]
                },

                // 附件
                accessoryList:[]
			}
		},

		onLoad(option) {
            // 人员详情
            this.getMemberDetail(option.id)
		},

    
		methods: {
            // 返回
            back(){
                uni.navigateBack()
            },


            // 菜单操作
            menuSkip(index){
                let url
                if( index==0 ) {
                    if( this.userInfo.isStartYdkq == 1 ){
                        url = '/pages/kaoqin-bag/member-clockin?bzbh='+this.staffInfo.bzid+'&rybh='+this.staffInfo.id
                    }else{
                        uni.$u.toast('当前项目未开通移动打卡')
                        return false
                    }
                }
                if( index==1 ) {
                    uni.$u.toast('无法获取工资发放明细Id')
                    return false
                    url = '/pages/wage-bag/member-detail?ywbh=工资发放明细ID&id='+this.staffInfo.id
                }
                if( index==2 ) url = '/pages/other-bag/credit?title=信用管理'
                if( index==3 ) url = '/pages/other-bag/credit?title=其它'
                uni.navigateTo({ url:url })
            },


            // 获取人员详情
            getMemberDetail(id){
                uni.showLoading({ title:'人员详情加载中' })
                const api = JSON.parse(JSON.stringify(this.$apis.MemberDetail))
                api.url = api.url+'/'+id
                this.$request(this,api,{}).then(res=>{
                    // console.log('人员详情',res)
                    // 人员详情
                    this.staffInfo = res
                    // 当前单位(企业)信息
                    this.enterpriseData.list.map((v,i)=>{
                        v.value = res[v.field]?res[v.field]:'暂无数据源'
                    })
                    // 当前项目信息
                    this.projectData.list.map((v,i)=>{
                        v.value = res[v.field]?res[v.field]:'暂无数据源'
                    })
                    // 人员信息
                    this.staffData.list.map((v,i)=>{
                        v.value = res[v.field]?res[v.field]:'暂无数据源'
                    })
                    // 合同信息 
                    this.contractInfo.list.map((v,i)=>{
                        v.value = res[v.field]?res[v.field]:'暂无数据源'
                    })
                    // 其他信息
                    this.otherInfo.list.map((v,i)=>{
                        if( v.field == 'sfcjjbaqpx' ){
                            v.value = res[v.field]?'是':'否'
                        }else{
                            v.value = res[v.field]?res[v.field]:'暂无数据源'
                        }
                    })
                    // 附件
                    this.getMemberAtta(res.ywlx,id)
                }).then()
            },


            // 单位(企业)详情
            entDetail(){
                if( this.staffInfo.qybm ){
                    uni.navigateTo({ url: '/pages/home-bag/ent-detail?id='+this.staffInfo.qybm })
                }else{
                    uni.$u.toast('人员详情中返回的企业编号为空')
                }
            },
            // 项目详情
            proDetail(){
                if( this.staffInfo.gcbh ){
                    uni.navigateTo({ url: '/pages/home-bag/pro-detail?id='+this.staffInfo.gcbh })
                }else{
                    uni.$u.toast('人员详情中返回的项目/工程编号为空')
                }
            },
            // 班组详情
            teamDetail(){
                if( this.staffInfo.bzid ){
                    uni.navigateTo({ url: '/pages/team-bag/detail?id='+this.staffInfo.bzid })
                }else{
                    uni.$u.toast('人员详情中返回的班组Id为空')
                }
            },

            // 附件
            getMemberAtta(ywlx,ywbh){
                uni.showLoading({ title:'附件信息加载中' }) 
                const parameter = {
                    ywlx: ywlx, // 业务类型【必传】
                    ywbh: ywbh, // 业务编号【必传】ryxx_21060204152800000299
                }
                this.$request(this, this.$apis.MemberAtta, parameter).then(res=>{
                    // console.log('项目附件',res)
                    this.accessoryList = res
                }).then() 
            }
		}
	}
</script>

<style scoped lang="scss">
    .content{
        // 个人信息
        .up{
            position: relative;
            // 认证
            .authentication{
                width: 162rpx;
                height: 44rpx;
                padding-right: 50rpx !important;
                position: absolute;
                top: 0;
                right: -60rpx;
            }
            .info{
                .info_item{
                    padding: 0 28rpx;
                    border-left: 1rpx solid #DFDFDF;
                    &:first-child{
                        padding-left: 0;
                        border: none;
                    }
                }
            }
        }
    }
</style>
